﻿using MediatR;
using Purchase.ApiS.ListDisplay.Command;
using Purchase.Domian.Model;
using Purchase.ErrorCode;
using Purchase.Infrastructrue.Implenment;

namespace Purchase.ApiS.ListDisplay.Hanlder
{
    public class GetInspectionDepCommandHanlder : IRequestHandler<GetInspectionDepCommand, ApiResult<List<InspectionDep>>>
    {
        public readonly IBaseRepostity<InspectionDep> _baseRequest;
        public readonly ILogger<GetInspectionDepCommandHanlder> logger;

        public GetInspectionDepCommandHanlder(IBaseRepostity<InspectionDep> baseRequest, ILogger<GetInspectionDepCommandHanlder> logger)
        {
            _baseRequest = baseRequest;
            this.logger = logger;
        }
        /// <summary>
        /// 获取检验部门信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>

        public Task<ApiResult<List<InspectionDep>>> Handle(GetInspectionDepCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<InspectionDep>> result = new ApiResult<List<InspectionDep>>();
            try
            {
                var list = _baseRequest.GetAll().ToList();
                result.Data = list;
                result.Msg = "获取检验部门信息成功";
                result.Code = ApiEume.Success;

            }
            catch (Exception ex)
            {

            }
            return Task.FromResult(result);
        }
    }
}
